package cn.itcast.controller;

import cn.itcast.domain.company.Company;
import cn.itcast.service.company.CompanyService;

import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import java.util.UUID;

@Controller
public class ApplyController {


    @Reference
    private CompanyService companyService;

    @ResponseBody
    @RequestMapping(value = "/apply",name = "申请企业入驻")
    public String apply(Company company){

        try {
            company.setId(UUID.randomUUID().toString());
            company.setState(0); /*状态码 0 代表没有审核*/
            companyService.save(company);
            return "1";

        } catch (Exception e) {
            /*发生异常返回0 */
            e.printStackTrace();
            return "0";
        }

    }
}
